<!DOCTYPE html>
<html>
<head>
	<title>选择封面</title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<script type="text/javascript" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/photoNewBook/jisuan.js"></script>
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="yes" name="apple-touch-fullscreen">
	<meta content="telephone=no,email=no" name="format-detection">
	<meta content="telephone=no,email=no" name="format-detection">
	<link rel="stylesheet" href="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/css/common.css?v={$WST_V}">
   <link rel="stylesheet" type="text/css" href="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/css/photoNewBook/templet.css"/>
   <link rel="stylesheet" href="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/css/photo_edit.css" type="text/css">
	<include file="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/common_js.html" />
  <link rel="stylesheet" type="text/css" href="../css/photoNewBook/titlpage.css"/>
  <style type="text/css">	  	
    	    	.whole{
    		margin-top: 0rem;
    	}
    	.Foot{
    		top: 1.3rem;
    		box-shadow:none;
    	}
    	.Conter {
		
		    margin-top: 1rem;
			}
.return {
    width: 100%;
    height: 1.3rem;
    background-color: #87E1D5;
    position: relative;
}
.return>.img_1 {
    margin-top: 0.4rem;
    width: 0.3rem;
    margin-left: 0.5rem;
}
.return>b {
    font-size: 0.5rem;
    position: absolute;
    margin-left: 33%;
    margin-top: 3%;
    color: #4C4C4C;
}
#front_cover0,#front_cover1,#front_cover2{
    display: block;
    width: 17%;
    height: .6rem;
    line-height: .6rem;
    background-color: #63e0ce;
    color: #fff;
    position: absolute;
    top: 65%;
    /* bottom: .05rem; */
    left: 0.45rem;
    font-size: .25rem;
    font-weight: normal;
    border-radius: 0.1rem;
    text-align: center;
}
#front_cover1{
	left: 37%;
}
#front_cover2{
	left:69%;
}

  </style>
</head>

<body>
		<!--返回上一页-->
<input type="hidden" name="" id="recurrence" value="0" />
			<div class="return">
			    <img src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/images/index/app/index/fanhui_zuo.png" alt="" class="img_1" onclick="Return()"/>
				<b>选择封面</b>
			</div>
            <div class="container" style="position: relative;">
            </div>
            <span class="" style="z-index:5" id="front_cover0">可上传图片</span>
            <span class="" style="z-index:5" id="front_cover1">可上传图片</span>
            <span class="" style="z-index:5" id="front_cover2">可上传图片</span>
</body>
<script type="text/javascript" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/photoNewBook/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/photoNewBook/ajax.js"></script>
<script type="text/javascript" src="../js/photoNewBook/titlpage.js"></script>
<script type="text/javascript" src="../js/photoNewBook/personal.js"></script>
<script type="text/javascript">
	
	// 这段代码是固定的，必须要放到js中
function setupWebViewJavascriptBridge(callback) {
    //Android
    if (window.GCWebviewAndroidJSBridge) {
        callback(GCWebviewAndroidJSBridge)
    } else {
        document.addEventListener(
                                  'GCWebviewAndroidJSBridgeReady'
                                  , function() {
                                  callback(GCWebviewAndroidJSBridge)
                                  },
                                  false
                                  );
    }
    
    //iOS
    if (window.GCWebviewJSBridge) {
        return callback(GCWebviewJSBridge);
    }
    if (window.KBWVJSBCallBacks) {
        return window.KBWVJSBCallBacks.push(callback);
    }
    window.KBWVJSBCallBacks = [callback];
    var GCWVJSBIframe = document.createElement('iframe');
    GCWVJSBIframe.style.display = 'none';
    GCWVJSBIframe.src = 'gcwvjsbscheme://__GC_BRIDGE_LOADED__';
    document.documentElement.appendChild(GCWVJSBIframe);
    setTimeout(function() { document.documentElement.removeChild(GCWVJSBIframe) }, 0);
}
    
        // 与OC交互的所有JS方法都要在这里注册,才能让OC和JS之间相互调用
        setupWebViewJavascriptBridge(function(bridge) {                                    
                                     /* OC给JS提供公开的API, 在JS中可以手动调用此API, 并且可以接收OC中传过来的参数,同时可回调OC */                                   
								
                                     // 封面1上传成功返回结果
                                     bridge.registerHandler('cover0', function(data, responseCallback) {
                                                            console.log("OC中传递过来的参数:", data);
                                                            // 把处理好的结果返回给OC
                                                            var cId=$('#cId').val();
                                                            var time=data.time;
                                                            var url=data.filepath;                                                
                                                            var pbId = sessionStorage.getItem("pbId");
                                                            var userId = sessionStorage.getItem("userId");                                                          
                                                            $.ajax({
                                                                   type:"POST",
																				 url:"http://www.youyiku-yishu.cn/WebApp/AppPhotoBooks/saveCoverImage",
																				 data:{url:url,pbId:pbId,cId:cId,userId:userId},
																				 dataType:"json",
																				 beforeSend: function (XMLHttpRequest) {
																	    			  XMLHttpRequest.setRequestHeader("DEVICEINFO", "JxRaZezavm3HXM3d9pWnYiqqQC1SJbsU");
																	       } 
                                                                  }).then(data=>{
											       					if(data.status==1){
								                              		    paper=''		                                   
									                                    paper += '<img  src="http://www.youyiku-yishu.cn/'+url+'">';
									                                    $('.imgbox1').html(paper);
									                                     $('.imgbox1').css('background-color','#FFFFFF');
									                                  }else{
									                                           alert('上传失败，请重新上传');
									                                   
									                                  }
                                                              })
                                                          });                                                                       
                                        // 封面2上传成功返回结果
                                     bridge.registerHandler('cover1', function(data, responseCallback) {
                                                            console.log("OC中传递过来的参数:", data);
                                                            // 把处理好的结果返回给OC
                                                            var cId=$('#cId').val();
                                                            var time=data.time;
                                                            var url=data.filepath;                                                      
                                                            var pbId = sessionStorage.getItem("pbId");
                                                            var userId = sessionStorage.getItem("userId");
                                                            $.ajax({
                                                                   type:"POST",
																				 url:"http://www.youyiku-yishu.cn/WebApp/AppPhotoBooks/saveCoverImage",
																				 data:{url:url,pbId:pbId,cId:cId,userId:userId},
																				 dataType:"json",
																				 beforeSend: function (XMLHttpRequest) {
																	    			  XMLHttpRequest.setRequestHeader("DEVICEINFO", "JxRaZezavm3HXM3d9pWnYiqqQC1SJbsU");
																	       } 
                                                                  }).then(data=>{                                                               
											       					if(data.status==1){
						
								                              		    paper=''		                                   
									                                    paper += '<img  src="http://www.youyiku-yishu.cn/'+url+'">';
									                                    $('.imgbox2').html(paper);
									                                     $('.imgbox2').css('background-color','#FFFFFF');
									                                  }else{
									                                           alert('上传失败，请重新上传');
									                                   
									                                  }
                                                              })
                                                          });                                                                       
                                        // 封面3上传成功返回结果
                                     bridge.registerHandler('cover2', function(data, responseCallback) {
                                                            console.log("OC中传递过来的参数:", data);
                                                            // 把处理好的结果返回给OC
                                                            var cId=$('#cId').val();
                                                            var time=data.time;
                                                            var url=data.filepath;
//                                                          alert(url);
                                                            var pbId = sessionStorage.getItem("pbId");
                                                            var userId = sessionStorage.getItem("userId");
                                                            $.ajax({
                                                                   type:"POST",
																				 url:"http://www.youyiku-yishu.cn/WebApp/AppPhotoBooks/saveCoverImage",
																				 data:{url:url,pbId:pbId,cId:cId,userId:userId},
																				 dataType:"json",
																				 beforeSend: function (XMLHttpRequest) {
																	    			  XMLHttpRequest.setRequestHeader("DEVICEINFO", "JxRaZezavm3HXM3d9pWnYiqqQC1SJbsU");
																	       } 
                                                                   }).then(data=>{
//                                                                        var	paper=''
											       					if(data.status==1){
						//		                                 	 alert('上传成功');
								                              		    paper=''		                                   
									                                    paper += '<img  src="http://www.youyiku-yishu.cn/'+url+'">';
									                                    $('.imgbox3').html(paper);
									                                     $('.imgbox3').css('background-color','#FFFFFF');
									                                  }else{
									                                           alert('上传失败，请重新上传');									                                   
									                                  }
                                                              })
                                                          });                                                                       
                                     
                                     // 手机上传 调用OC中的打开相册方法 封面1
                                     document.getElementById('front_cover0').onclick = function () {                                    	
                                     bridge.callHandler('openNativeAlbum', {'maxNum':'1','cover':'0'}, function responseCallback(responseData) {
                                                        console.log("OC中返回的参数:", responseData)
                                                        });
                                     };
                                     // 手机上传 调用OC中的打开相册方法 封面2
                                     document.getElementById('front_cover1').onclick = function () {
                                     	var cover=1;
                                     bridge.callHandler('openNativeAlbum', {'maxNum':'1','cover':'1'}, function responseCallback(responseData) {
                                                        console.log("OC中返回的参数:", responseData)
                                                        });
                                     };
                                     // 手机上传 调用OC中的打开相册方法 封面3
                                     document.getElementById('front_cover2').onclick = function () {
                                     bridge.callHandler('openNativeAlbum', {'maxNum':'1','cover':'2'}, function responseCallback(responseData) {
                                                        console.log("OC中返回的参数:", responseData)
                                                        });
                                     };
                        
      });  
     
</script>
</script>
</html>

